<template>

姓名:<input type="text" v-model="Sousup.name">

状态:<select v-model="Sousup.state" >

    <option :value="null">---请选择---</option>
    <option  :value="true" >可以入住</option>
    <option  :value="false" >打扫中</option>
</select>

<button  @click="Show" class="btn btn-success" >搜索</button>
<table  class="table table-bordered">
<thead>
    <tr>
        <th>
            <input type="checkbox" @change="QuanXuan" v-model="quanxuan1" >
        </th>
      
    <th>房号id</th>
    <th>房号名称</th>
    <th>楼层</th>
    <th>房间号</th>
    <th>房号状态</th>
    <th>操作</th>
</tr>
</thead>

<tbody v-for="item in Show1">

    <tr>
        <th>
            <input type="checkbox"  :checked="fanxuan1" :value="item.Rnumber_id"  v-model="arrid"  @change="FanXuan2">
        </th>
    <th>{{ item.Rnumber_id}}</th>
    <th>{{ item.Rnumber_Name }}</th>
    <th>{{ item.Rnumer_Floor }}</th>
    <th>{{ item.Rnumber_Num }}</th>
    <th>{{ item.Rnumer_State?"可以入住":"打扫中" }}</th>
    <th><button @click="Isdel(item.Rnumber_id)" class="btn btn -success" >删除</button>
        <a href="#" @click="Xg(item.Rnumber_id)">修改</a>
    
    </th>
   
        </tr>

</tbody>



</table>


数据总共:<span style="color: red;">{{Fenye1.count  }}条 </span>,每页显示<span style="color: red;">{{ Fenye1.m}}条</span>,当前<span style="color: red;">{{ Fenye1.Zy }}</span>/<span style="color: red;">{{Fenye1.s  }}</span>页


<button @click="FenYe('S')">首页</button>
<button @click="FenYe('L')">上一页</button>
<button @click="FenYe('N')">下一页</button>
<button @click="FenYe('M')">尾页</button>




</template>

<script setup lang="ts">
import {useRouter,createRouter} from 'vue-router'
const router=useRouter();

const Xg=(id:number)=>{


    router.push({

        name:'XgRoom',
        params:{


            id:id,
        }
        



})


}


const fanxuan1=ref(false);

const quanxuan1=ref(false);

const arrid =ref([]);
const QuanXuan=()=>{

        if(quanxuan1.value==true)
        {
       
            fanxuan1.value=true;
     
            arrid.value= Show1.value.map((item:any)=>{

                return item.Rnumber_id
            })
            alert(arrid.value )
        }
        else
        {
            fanxuan1.value=false;
      
        }

    

}

const FanXuan2=()=>{

    if(arrid.value.length==Show1.value.length)
{
    quanxuan1.value=true
}
else
{
    quanxuan1.value=false;
}
}






 const FenYe=(chool:string  )=>{

        switch(chool){
                    case 'S':

                    Fenye1.value.s=1
                    break;

                    case 'L':
                    if(Fenye1.value.s<=1)
                    {alert('页码不能小于1')
                        return ;
                    }
                    Fenye1.value.s-=1;
                    break;
                    
                    case 'N':
                    if(Fenye1.value.s>=Fenye1.value.Zy)
                    {alert('页码不能大于总页')
                        return ;
                        
                    }
                    Fenye1.value.s+=1;
                    break;

                    case 'M':
                 
                    Fenye1.value.s=Fenye1.value.Zy;
                    break;

                 

        };

                        Show();



 }
import axios from 'axios';
import { onMounted ,ref} from 'vue';



onMounted(()=>{

    Show();
})

const Show1 =ref([{

    "Rnumber_id": 0,
  "Rnumber_Name": "string",
  "Rnumer_Floor": 0,
  "Rnumber_Num": 0,
  "Rnumer_State": true,
  "Rnumber_IsDel": true,
  "RnumberDeleteTime": "2024-12-25T05:37:48.196Z"


}])


const Show=()=>{

  
        axios.get('https://localhost:7035/api/T_Room/ShowRoomNumber',{params:{

            rnName:Sousup.value.name,
            rnState:Sousup.value.state,
            s:Fenye1.value.s,
            m:Fenye1.value.m,

             
        }}).then(res=>{

            Show1.value=res.data.PageData


                Fenye1.value.count=res.data.TotalCount,
                Fenye1.value.Zy=res.data.PageCount
        })

}



const Sousup=ref({

        state:null,
        name:"",

})


const Fenye1=ref({


    s:1,
    m:3,
    count:0,
    Zy:0,
})




const Isdel=(id:number)=>{

   
    arrid.value
    if(!confirm('确认删除吗'))
{
    return ;
}
if(id!=0)
{
    alert(1)
    axios.delete('https://localhost:7035/api/T_Room/DelRoom',{params:{
        id:id                                                                                                                            
    }}).then(res=>{

        if(res.data>0)
    {
        alert('删除成功')
    }
    else
    {
        alert('删除失败')
    }
    })
}
else
{
    axios.delete('https://localhost:7035/api/T_Room/DelRoom',{params:{
        id:arrid.value                                                                                                                                
    }}).then(res=>{

        if(res.data>0)
    {
        alert('删除成功')
    }
    else
    {
        alert('删除失败')
    }
    })
}
 
}

</script>